const http=require("http");
const fs=require("fs");
let server=http.createServer((request,response)=>{
    let url=request.url;
    response.writeHead(200,{"Content-Type":"text/html;charset=utf-8"})
    if (url=="/a"){
        let readFileSync=fs.readFileSync("a.html");
        response.end(readFileSync);
    }else if (url=="/b"){
        let result=fs.readFileSync("b.html");
        response.end(result);
    }else if(url.endsWith(".jpg")){
        response.writeHead(200,{"Content-Type":"image/jpg;charset=utf-8"})
        let photo=fs.readFileSync("timg.jpg");
        response.end(photo)
    } else {
        response.end("非法操作！")
    }
})
server.listen(8888,()=>{
    console.log("服务器启动成功")
})